package com.liuzhilong.infrastructure.basic.command.simple;

import lombok.AccessLevel;
import lombok.Setter;
import lombok.experimental.Accessors;

@Setter(AccessLevel.PRIVATE)
@Accessors(chain = true)
public class OneCommand implements Command {

    private OneReceiver oneReceiver;

    @Override
    public void execute() {
        System.out.println(this.getClass().getName()+" 先执行OneReceiver的doGetFirst");
        String r = oneReceiver.doGetFirst();
        System.out.println(this.getClass().getName()+" 再执行OneReceiver的doLast");
        oneReceiver.doLast(r);
    }

    public static final OneCommand create(OneReceiver oneReceiver){
        return new OneCommand().setOneReceiver(oneReceiver);
    }
}
